home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
-
- /*******************************************************************************
- BookFile.c
-
- *******************************************************************************/
-
- #include <stdio.h>
- #include <unistd.h>
- #include <Xm/Xm.h>
- #include <Xm/DialogS.h>
- #include <Xm/MenuShell.h>
- #include "UxXt.h"
-
- #include <Xm/FileSB.h>
-
- /*******************************************************************************
- Includes, Defines, and Global variables from the Declarations Editor:
- *******************************************************************************/
-
- #include "exinterfmotif.h"
- #include <string.h>
- #include "exglobals.h"
- /*
- #include "exinterf.h"
- */
-
- /*******************************************************************************
- The definition of the context structure:
- If you create multiple instances of your interface, the context
- structure ensures that your callbacks use the variables for the
- correct instance.
-
- For each Widget in the interface, each argument to the Interface
- function, and each variable in the Instance Specific section of the
- Declarations Editor, there is an entry in the context structure.
- and a #define. The #define makes the variable name refer to the
- corresponding entry in the context structure.
- *******************************************************************************/
-
- typedef struct
- {
- int mumble;
- } _UxCBookFile;
-
-
- static _UxCBookFile *UxBookFileContext;
-
- Widget BookFile;
-
- /*******************************************************************************
- Forward declarations of functions that are defined later in this file.
- *******************************************************************************/
-
- Widget create_BookFile();
-
- /*******************************************************************************
- The following are callback functions.
- *******************************************************************************/
-
- static void okCallback_BookFile( UxWidget, UxClientData, UxCallbackArg )
- Widget UxWidget;
- XtPointer UxClientData, UxCallbackArg;
- {
- _UxCBookFile *UxSaveCtx, *UxContext;
-
- UxSaveCtx = UxBookFileContext;
- UxBookFileContext = UxContext =
- (_UxCBookFile *) UxGetContext( UxWidget );
- {
- XmFileSelectionBoxCallbackStruct *cbs;
- cbs = (XmFileSelectionBoxCallbackStruct *)UxCallbackArg;
- FileName = extract_first_xms_segment(cbs->value);
- if (strlen(FileName) == 0) {
- sprintf(msgstring, "Invalid Book File Name");
- DialogType = 1;
- popup_Message();
- }
- else if (FileMode == 2) { /* Write File */
- if (access(FileName, F_OK) != 0) {
- RDwin = -1;
- UxPopdownInterface(BookFile);
- InterfaceWinOpen-- ;
- if (ASCII)
- write_ascii(FileName);
- else
- write_file(FileName);
- }
- else {
- DialogType = 4;
- popup_Question();
- UxWaitForNotify();
- }
- }
- else if (FileMode == 1) { /* Read File */
- if (access(FileName, F_OK) != 0) {
- sprintf(msgstring, "Invalid Book File Name");
- DialogType = 1;
- popup_Message();
- }
- else {
- RDwin = -1;
- UxPopdownInterface(BookFile);
- InterfaceWinOpen-- ;
- read_file(FileName);
- drawscene(0);
- if (message_waiting) {
- popup_Message();
- message_waiting = FALSE;
- }
- }
- }
- }
- UxBookFileContext = UxSaveCtx;
- }
-
- static void cancelCB_BookFile( UxWidget, UxClientData, UxCallbackArg )
- Widget UxWidget;
- XtPointer UxClientData, UxCallbackArg;
- {
- _UxCBookFile *UxSaveCtx, *UxContext;
-
- UxSaveCtx = UxBookFileContext;
- UxBookFileContext = UxContext =
- (_UxCBookFile *) UxGetContext( UxWidget );
- {
- RDwin = -1;
- UxPopdownInterface(BookFile);
- InterfaceWinOpen-- ;
- }
- UxBookFileContext = UxSaveCtx;
- }
-
- /*******************************************************************************
- The 'build_' function creates all the Widgets and X widgets,
- and sets their properties to the values specified in the
- Property Editor.
- *******************************************************************************/
-
- Widget BookFile_shell;
-
- static Widget _Uxbuild_BookFile()
- {
-
- BookFile_shell = XtVaCreatePopupShell( "BookFile_shell",
- xmDialogShellWidgetClass, DBtoplevel,
- XmNx, 725,
- XmNy, 237,
- XmNwidth, 340,
- XmNheight, 420,
- XmNtitle, "BookFile",
- NULL );
-
- BookFile = XtVaCreateWidget( "BookFile",
- xmFileSelectionBoxWidgetClass, BookFile_shell,
- XmNtextColumns, 32,
- XmNminimizeButtons, FALSE,
- XmNlistVisibleItemCount, 8,
- XmNdialogType, XmDIALOG_FILE_SELECTION,
- RES_CONVERT( XmNtextFontList, "-Adobe-Courier-Bold-R-Normal--14-100-100-100-M-90-ISO8859-1" ),
- XmNresizePolicy, XmRESIZE_ANY,
- XmNnoResize, FALSE,
- XmNmarginWidth, 10,
- XmNmarginHeight, 10,
- RES_CONVERT( XmNlabelFontList, "-Adobe-Helvetica-Bold-R-Normal--14-100-100-100-P-82-ISO8859-1" ),
- RES_CONVERT( XmNdialogTitle, "BookFile" ),
- XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
- RES_CONVERT( XmNbuttonFontList, "-Adobe-Helvetica-Bold-R-Normal--14-100-100-100-P-82-ISO8859-1" ),
- /*
- XmNshadowThickness, 5,
- RES_CONVERT( XmNforeground, "black" ),
- RES_CONVERT( XmNbottomShadowColor, "#6c6c6c" ),
- RES_CONVERT( XmNtopShadowColor, "#e5e5e5" ),
- RES_CONVERT( XmNbackground, "#BBBBBB" ),
- */
- XmNheight, 420,
- XmNwidth, 340,
- NULL );
-
- UxPutContext( BookFile, (char *) UxBookFileContext );
-
- XtAddCallback( BookFile, XmNdestroyCallback,
- UxFreeClientDataCB,
- (XtPointer) UxBookFileContext );
-
- XtAddCallback( BookFile, XmNokCallback,
- okCallback_BookFile,
- (XtPointer) UxBookFileContext );
- XtAddCallback( BookFile, XmNcancelCallback,
- cancelCB_BookFile,
- (XtPointer) UxBookFileContext );
-
-
- return ( BookFile );
- }
-
- /*******************************************************************************
- The following function includes the code that was entered
- in the 'Initial Code' and 'Final Code' sections of the
- Declarations Editor. This function is called from the
- 'Interface function' below.
- *******************************************************************************/
-
- static Widget _Ux_create_BookFile()
- {
- Widget rtrn;
- _UxCBookFile *UxContext;
- char dir_mask[128];
- char dir_spec[128];
- char *cwd;
- char buf[128];
-
- UxBookFileContext = UxContext =
- (_UxCBookFile *) XtMalloc( sizeof(_UxCBookFile) );
-
- rtrn = _Uxbuild_BookFile();
-
- if ((cwd = getcwd(buf, 128)) == NULL) {
- printf("Error in getcwd. Setting a default directory.\n");
- strcpy(dir_spec, ".");
- }
- else
- strcpy(dir_spec, cwd);
- strcat (dir_spec, "/");
- strcpy (dir_mask, dir_spec);
- strcat (dir_mask, "*.out");
- XtVaSetValues( BookFile,
- RES_CONVERT( XmNdirMask, dir_mask ), NULL );
- XtVaSetValues( BookFile,
- RES_CONVERT( XmNdirSpec, dir_spec ), NULL );
-
- /*
- XtVaSetValues( XmFileSelectionBoxGetChild(BookFile, XmDIALOG_TEXT),
- RES_CONVERT( XmNbackground, "#7777BB" ), NULL );
- XtVaSetValues( XmFileSelectionBoxGetChild(BookFile, XmDIALOG_FILTER_TEXT),
- RES_CONVERT( XmNbackground, "#7777BB" ), NULL );
- XtVaSetValues( XmFileSelectionBoxGetChild(BookFile, XmDIALOG_DIR_LIST),
- RES_CONVERT( XmNbackground, "#7777BB" ), NULL );
- XtVaSetValues( XmFileSelectionBoxGetChild(BookFile, XmDIALOG_FILE_LIST),
- RES_CONVERT( XmNbackground, "#7777BB" ), NULL );
- */
-
- XtRealizeWidget( BookFile_shell );
-
- XtUnmanageChild(XmFileSelectionBoxGetChild(
- (BookFile), XmDIALOG_HELP_BUTTON));
-
- SetWMhints ( BookFile_shell );
-
- return(rtrn);
- }
-
- /*******************************************************************************
- The following is the 'Interface function' which is the
- external entry point for creating this interface.
- This function should be called from your application or from
- a callback function.
- *******************************************************************************/
-
- Widget create_BookFile()
- {
- Widget _Uxrtrn;
-
- _Uxrtrn = _Ux_create_BookFile();
-
- return ( _Uxrtrn );
- }
-
- /*******************************************************************************
- END OF FILE
- *******************************************************************************/
-
-